/**
  @file     	DESIGNPATTERN_ComplexFactory.h
  @brief    	1. Define an interface for creating an object, and the package object is created
                2. The work of the specific class of delay to sub-class
  @author  	arvin
  @version 	1.0   2012/12/14
 */
#include "stdafx.h"

#ifndef CXX_DESIGNPATTERN_COMPLEXFACTORY_H
#include "DESIGNPATTERN_ComplexFactory.h"
#endif

#ifndef CXX_COMPLEXFACTORY_H
#include "Profession.h"
#endif

/**
* Construction
*
* @param PROFESSION_TYPE eProfession
* @return 
*/
ComplexFactory::ComplexFactory(PROFESSION_TYPE eProfession) :
	m_eProfession(eProfession)
{
	DEBUG_PRINTF("m_eProfession[%d], Profession[%s]", m_eProfession, STATIC_CONST_STRING_PROFESSION[m_eProfession].c_str());
}

/**
* Destruction
*
* @param VOID
* @return 
*/
ComplexFactory::~ComplexFactory()
{
	DEBUG_PRINTF("m_eProfession[%d], Profession[%s]", m_eProfession, STATIC_CONST_STRING_PROFESSION[m_eProfession].c_str());
}


/**
* Create Profession
*
* @param VOID
* @return Profession* 
* @note
*/
Profession* 
ComplexFactory::CreateProfession()
{
	//system error log
	DEBUG_PRINTF("m_eProfession[%d], Profession[%s]", m_eProfession, STATIC_CONST_STRING_PROFESSION[m_eProfession].c_str());

	return NULL;
}

/**
* Operation
*
* @param PROFESSION_TYPE eProfession
* @return
*/
VOID 
ComplexFactory::SetComplexFactory(PROFESSION_TYPE eProfession)
{
	DEBUG_PRINTF("m_eProfession[%d], Profession[%s]", m_eProfession, STATIC_CONST_STRING_PROFESSION[m_eProfession].c_str());
	m_eProfession = eProfession;
}

/**
* Operation
*
* @param VOID
* @return PROFESSION_TYPE
*/
PROFESSION_TYPE
ComplexFactory::GetComplexFactory()
{
	DEBUG_PRINTF("m_eProfession[%d], Profession[%s]", m_eProfession, STATIC_CONST_STRING_PROFESSION[m_eProfession].c_str());
	return m_eProfession;
}

WarriorFactory* WarriorFactory::m_pInstance = NULL;

/**
* Construction
*
* @param VOID
* @return 
*/
WarriorFactory::WarriorFactory() :
	ComplexFactory(PROFESSION_WARRIOR)
{
	DEBUG_PRINTF("");
}

/**
* Destruction
*
* @param VOID
* @return 
*/
WarriorFactory::~WarriorFactory()
{
	DEBUG_PRINTF("");
}

/**
* Instance
*
* @param VOID
* @return ComplexFactory*
* @note singleton
*/
ComplexFactory* 
WarriorFactory::Instance()
{
	DEBUG_PRINTF("");
	if (NULL == m_pInstance) {
		m_pInstance = new WarriorFactory;
	}
	return m_pInstance;
}


/**
* Destroy
*
* @param VOID
* @return VOID
* @note singleton
*/
VOID 
WarriorFactory::Destroy()
{
	DEBUG_PRINTF("");
	if (NULL != m_pInstance) {
		delete m_pInstance;
		m_pInstance = NULL;
	}
}

/**
* Create Profession
*
* @param VOID
* @return Profession* 
* @note create Warrior
*/
Profession* 
WarriorFactory::CreateProfession()
{
	DEBUG_PRINTF("");
	return new Warrior;
}

MasterFactory* MasterFactory::m_pInstance = NULL;


/**
* Construction
*
* @param VOID
* @return 
*/
MasterFactory::MasterFactory() :
	ComplexFactory(PROFESSION_MASTER)
{
	DEBUG_PRINTF("");
}

/**
* Destruction
*
* @param VOID
* @return 
*/
MasterFactory::~MasterFactory()
{
	DEBUG_PRINTF("");
}

/**
* Instance
*
* @param VOID
* @return ComplexFactory*
* @note singleton
*/
ComplexFactory* 
MasterFactory::Instance()
{
	DEBUG_PRINTF("");
	if (NULL == m_pInstance) {
		m_pInstance = new MasterFactory;
	}
	return m_pInstance;
}


/**
* Destroy
*
* @param VOID
* @return VOID
* @note singleton
*/
VOID 
MasterFactory::Destroy()
{
	DEBUG_PRINTF("");
	if (NULL != m_pInstance) {
		delete m_pInstance;
		m_pInstance = NULL;
	}
}

/**
* Create Profession
*
* @param VOID
* @return Profession* 
* @note create Master
*/
Profession* 
MasterFactory::CreateProfession()
{
	DEBUG_PRINTF("");
	return new Master;
}

PriestFactory* PriestFactory::m_pInstance = NULL;


/**
* Construction
*
* @param VOID
* @return
*/
PriestFactory::PriestFactory() :
	ComplexFactory(PROFESSION_PRIEST)
{
	DEBUG_PRINTF("");
}

/**
* Destruction
*
* @param VOID
* @return
*/
PriestFactory::~PriestFactory()
{
	DEBUG_PRINTF("");
}

/**
* Instance
*
* @param VOID
* @return ComplexFactory*
* @note singleton
*/
ComplexFactory*
PriestFactory::Instance()
{
	DEBUG_PRINTF("");
	if (NULL == m_pInstance) {
		m_pInstance = new PriestFactory;
	}
	return m_pInstance;
}


/**
* Destroy
*
* @param VOID
* @return VOID
* @note singleton
*/
VOID
PriestFactory::Destroy()
{
	DEBUG_PRINTF("");
	if (NULL != m_pInstance) {
		delete m_pInstance;
		m_pInstance = NULL;
	}
}

/**
* Create Profession
*
* @param VOID
* @return Profession*
* @note create Priest
*/
Profession*
PriestFactory::CreateProfession()
{
	DEBUG_PRINTF("");
	return new Priest;
}
/* EOF */